<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>美兰数据文化馆与图书馆</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/public.css" media="all">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/huazhi/images/favicon.ico"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row">
                <div class="layui-tab layui-tab-brief" lay-filter="component-tabs-hash">
                    <ul class="layui-tab-title">
                        <li class="layui-this" lay-id="33">参数预警信息设置</li>
                      <%--  <li lay-id="11">场地巡检信息设置</li>--%>
                    </ul>
                    <div class="layui-tab-content" style="height: auto">
                        <div class="layui-tab-item layui-show">
                            <table class="layui-hide" id="earlywarninig" lay-filter="earlywarninigs" ></table>
                        </div>
<%--                        <div class="layui-tab-item">--%>
<%--                            <table id="inspectionSite" lay-filter="inspectionSiteList"></table>--%>
<%--                            <div id="laypage"></div>--%>
<%--                        </div>--%>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="curnum" value="1">
<script type="text/html" id="inspectionDemo">
    <shiro:hasPermission name="sys:basicParameter:add">
        <div class="layui-inline" lay-event="add" title="添加">
            <i class="layui-icon layui-icon-add-1"></i>
        </div>
    </shiro:hasPermission>
</script>
<%--<script type="text/html" id="table-inspection-webuser">--%>
<%--    <a class="layui-btn layui-btn-xs" lay-event="hairpin">标签录入</a>--%>
<%--    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>--%>
<%--</script>--%>
<script src="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/layui.all.js"></script>
<script>
    layui.use([ 'table', 'laydate','laypage'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table
            , layer = layui.layer
            , laydate = layui.laydate,
            laypage=layui.laypage;

        table.render({
            elem: '#earlywarninig'
            , url: "<%=request.getContextPath()%>/rest/system/earlyWarningList"
            ,title:"预警参数设置",
            height: 'full'
            , page: false
            , limit: 10
            , text: {
                none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            },
            defaultToolbar: ['filter']
            // ,skin: 'line' //表格风格
            , cols: [[
                // {type: 'checkbox'}
                    {field: 'explains', title: '参数说明'}
                , {field: 'value', title: '参数值',edit: 'text'}
                , {field: 'name', title: '变量名称'}
            ]],
        });


        //监听单元格编辑
        table.on('edit(earlywarninigs)', function (obj) {
            var value = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
                , field = obj.field; //得到字段
//            layer.msg('[ID: '+ data.tid +'] ' + field + ' 字段更改为：'+ value);
            if (value == "") {
                layer.msg("参数值必填");
            } else if (!(/(^[1-9]\d*$)/.test(value))) {
                layer.msg("参数值输入的值不正确");
            } else {
                $.ajax({
                    type: "post",
                    url: "<%=request.getContextPath()%>/rest/system/updateEarlyWarning",
                    data: "tid=" + data.tid + "&value=" + value,
                    dataType: "json",
                    async: false,
                    success: function (data) {
                        if (data == true) {
                            layer.msg("修改成功");
                        } else {
                            layer.msg(data.errorMsg);
                        }
                    }
                })
            }
        });


        var limitcount = 10;
        table.render({
            elem: '#inspectionSite'
            , url: "<%=request.getContextPath()%>/rest/system/inspectionSiteList"
            ,title:"场地巡检表",
            height: 'full-186'
            , page: false
            , limit: limitcount
            , text: {
                none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            },
            defaultToolbar: ['filter',,'print']
            // ,skin: 'line' //表格风格
            , toolbar: '#inspectionDemo'
            , cols: [[
                // {type: 'checkbox'}
                {title: 'ID', width: 70, sort: true, fixed: 'left', type: 'numbers'}
                , {field: 'inspectionname', title: '场地名称', sort: true}
                , {field: 'inspectionepc', title: '场地标签', sort: true}
                , {field: 'createtimestring', title: '创建时间', sort: true}
                // , {title: '操作', toolbar: '#table-inspection-webuser',  align: "center", width: 200}
            ]],
            done: function (res, curr, count) {
                if(res.errorMsg==null){

                }else {
                    layer.msg(res.errorMsg);
                }
                $('.layui-table-fixed-r').removeClass('layui-hide');//列固定右侧
                var curnum = $("#curnum").val();
                laypage.render({
                    elem: 'laypage'
                    ,first: '首页'
                    ,last: '尾页'
                    ,groups:5
                    , count: count
                    , curr: curnum
                    , limit: limitcount
                    , layout: ['prev', 'page', 'next', 'skip', 'count','limit']
                    , limits:[10,15,20]
                    , jump: function (obj, first) {
                        if (!first) {
                            curnum = obj.curr;
                            $("#curnum").val(curnum)
                            limitcount = obj.limit;
                            table.reload('inspectionSite', { //表格的id
                                where: {
                                    page: curnum,
                                    limit:limitcount
                                }
                            })
                        }
                    }
                })
            }
        });

        //监听头工具栏事件
        table.on('toolbar(inspectionSiteList)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id)
                , data = checkStatus.data;//获取选中的数据
            switch (obj.event) {
                case 'add':
                    add(data);
                    break;
            }
            ;
        });

        function add() {
            alert("fdasfsd")
        }

        // //监听工具条
        // table.on('tool(inspectionSiteList)', function(obj){  //表格的lay-filter="userlists"
        //     var data = obj.data; //获得当前行所有数据
        //     var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
        //     var tr = obj.tr; //获得当前行 tr 的DOM对象
        //     if(obj.event === 'del'){
        //         deletes(data,obj);
        //     }
        // });


        <%--function add() {--%>
        <%--    var sss = '<div class="layui-fluid">' +--%>
        <%--        '    <div class="layui-row layui-col-space15">' +--%>
        <%--        '        <div class="layui-col-md12">' +--%>
        <%--        '                  <form class="layui-form" action="">' +--%>
        <%--        '                                  <div class="layui-form-item">' +--%>
        <%--        '                                    <label class="layui-form-label">场地名称</label>' +--%>
        <%--        '                                    <div class="layui-input-block">' +--%>
        <%--        '                                       <input type="text" name="inspectionname" id="inspectionname" autocomplete="off" placeholder="请输入场地名称" class="layui-input">' +--%>
        <%--        '                                    </div>' +--%>
        <%--        '                                    </div>' +--%>
        <%--        '                           <div class="layui-form-item">' +--%>
        <%--        '                                <label class="layui-form-label">创建时间</label>' +--%>
        <%--        '                                <div class="layui-input-block">' +--%>
        <%--        '                                    <input name="createtime" id="createtime"  autocomplete="off" class="layui-input" type="text">' +--%>
        <%--        '                                </div>' +--%>
        <%--        '                        </div>' +--%>
        <%--        '               </form>' +--%>
        <%--        '        </div>' +--%>
        <%--        '    </div>' +--%>
        <%--        '</div>'--%>

        <%--    var indexss = layer.open({--%>
        <%--        title: "添加场地巡检信息",--%>
        <%--        type: 1,--%>
        <%--        area: ['30%', '40%'],--%>
        <%--        content: sss,--%>
        <%--        shade: 0.8,--%>
        <%--        btn: ['确定', '取消'],--%>
        <%--        anim: 4,--%>
        <%--        skin: 'layui-layer-molv',--%>
        <%--        resize: true,--%>
        <%--        yes: function (index, layero) {--%>
        <%--            var inspectionnames = $("#inspectionname").val();--%>
        <%--            var createtime = $("#createtime").val();--%>
        <%--            if (inspectionnames == "") {--%>
        <%--                var inspectionname = document.getElementById("inspectionname");--%>
        <%--                inspectionname.setAttribute("class", "layui-input layui-form-danger");--%>
        <%--                inspectionname.focus();--%>
        <%--                layer.msg('场地名必填', {icon: 5, shift: 0});--%>
        <%--            } else {--%>
        <%--                $.ajax({--%>
        <%--                    type: "post",--%>
        <%--                    url: "<%=request.getContextPath()%>/rest/inspection/inspectionName",--%>
        <%--                    data: "inspectionname=" + inspectionnames,--%>
        <%--                    dataType: "json",--%>
        <%--                    async: false,--%>
        <%--                    success: function (data) {--%>
        <%--                        if (data == true) {--%>
        <%--                            layer.close(indexss);--%>
        <%--                            var index = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});--%>
        <%--                            setTimeout(function () {--%>
        <%--                                $.ajax({--%>
        <%--                                    type: "post",--%>
        <%--                                    url: "<%=request.getContextPath()%>/rest/inspection/inspectionAdd",--%>
        <%--                                    data: "inspectionname=" + inspectionnames + "&createtime=" + createtime,--%>
        <%--                                    dataType: "json",--%>
        <%--                                    async: false,--%>
        <%--                                    success: function (data) {--%>
        <%--                                        layer.close(index);--%>
        <%--                                        if (data != -1) {--%>
        <%--                                            layer.msg('添加成功');--%>
        <%--                                            table.reload('inspectionSite')--%>
        <%--                                        } else {--%>
        <%--                                            layer.msg('添加失败');--%>
        <%--                                        }--%>
        <%--                                    }--%>
        <%--                                })--%>
        <%--                            }, 2000);--%>
        <%--                        } else {--%>
        <%--                            var inspectionname = document.getElementById("inspectionname");--%>
        <%--                            inspectionname.setAttribute("class", "layui-input layui-form-danger");--%>
        <%--                            inspectionname.focus();--%>
        <%--                            layer.msg('场地名称已存在', {icon: 2, shift: 0});--%>
        <%--                        }--%>
        <%--                    }--%>
        <%--                })--%>
        <%--            }--%>
        <%--        }--%>

        <%--    });--%>

        <%--    var date = new Date();--%>
        <%--    var year = date.getFullYear();--%>
        <%--    var month = date.getMonth() + 1;--%>
        <%--    var date = date.getDate();--%>
        <%--    var now = year + '-' + p(month) + "-" + p(date);--%>

        <%--    function p(s) {--%>
        <%--        return s < 10 ? '0' + s : s;--%>
        <%--    }--%>

        <%--    //日期--%>
        <%--    laydate.render({--%>
        <%--        elem: '#createtime',--%>
        <%--        btns: ['now', 'confirm'],--%>
        <%--        theme: 'molv',--%>
        <%--        calendar: true,--%>
        <%--        value: now--%>
        <%--    });--%>

        <%--}--%>


    });
</script>
</body>
</html>
